/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package solitairetest.logic;

/**
 *
 * @author Viktor
 */
public class Card
{
    private char suit;
    private int rank;
    private boolean facing; // True == up, False == down

    public static char[] suits;

    static {
        suits = new char[] {
            'H',
            'S',
            'D',
            'C'
        };
    }

    public Card(char suit, int rank) throws CardException
    {
            this(suit, rank, false);
    }

    public Card(char suit, int rank, boolean facing) throws CardException
    {
        if ((rank < 14 || rank == 999) && (suit == 'H' || suit == 'S' || suit == 'D' || suit == 'C'))
        {
            this.suit = suit;
            this.rank = rank;
            this.facing = facing;
        }
        else
            throw new CardException("Unknown suit or rank, S:" + suit + ",R:" + rank);
    }
    
    public char GetSuit()
    {
        return this.suit;
    }

    public char SetSuit(char suit)
    {
        if (suit == 'H' || suit == 'S' || suit == 'D' || suit == 'C')
            this.suit = suit;

        return this.suit;
    }

    public int GetRank()
    {
        return this.rank;
    }

    public int SetRank(int rank)
    {
        if (rank < 14)
            this.rank = rank;

        return this.rank;
    }

   /**
    * @return <tt>true</tt> facing up.
    * <tt>false</tt> facing down.
    */
    public boolean GetFacing()
    {
        return this.facing;
    }

    /**
     * @param facing <tt>true</tt> facing up, <tt>false</tt> facing down.
     */
    public boolean SetFacing(boolean facing)
    {
        this.facing = facing;

        return this.facing;
    }
}